package com.fr.report.painter;

import com.fr.base.FRContext;
import com.fr.base.FRFont;
import com.fr.base.StringUtils;
import com.fr.base.Style;
import com.fr.base.background.Background;
import com.fr.base.background.ColorBackground;
import com.fr.base.xml.XMLableReader;
import com.fr.report.cellElement.BarcodeAttr;
import com.fr.report.core.barcode.BarCodeUtils;
import com.fr.report.core.barcode.BarcodeException;
import com.fr.report.core.barcode.BarcodeImpl;
import java.awt.Graphics;
import java.awt.Graphics2D;
import java.util.logging.Level;
import java.util.logging.Logger;

public class BarcodePainter extends AbstractPainter
{
  private String text = null;
  private BarcodeAttr barcodeAttr;

  public BarcodePainter(BarcodeAttr paramBarcodeAttr, String paramString)
  {
    this.barcodeAttr = paramBarcodeAttr;
    setText(paramString);
  }

  public BarcodeAttr getBarcodeAttr()
  {
    return this.barcodeAttr;
  }

  public void setBarcodeAttr(BarcodeAttr paramBarcodeAttr)
  {
    this.barcodeAttr = paramBarcodeAttr;
  }

  public String getText()
  {
    return this.text;
  }

  public void setText(String paramString)
  {
    if (StringUtils.containChinese(paramString))
      this.text = null;
    else
      this.text = paramString;
  }

  public void paint(Graphics paramGraphics, int paramInt1, int paramInt2, Style paramStyle)
  {
    if (this.text == null)
      return;
    try
    {
      BarcodeImpl localBarcodeImpl = BarCodeUtils.getBarcodeImpl(this);
      if (paramStyle.getFRFont() != null)
      {
        localBarcodeImpl.setFont(paramStyle.getFRFont());
        localBarcodeImpl.setForeground(paramStyle.getFRFont().getForeground());
      }
      Background localBackground = paramStyle.getBackground();
      if ((localBackground != null) && (localBackground instanceof ColorBackground))
        localBarcodeImpl.setBackground(((ColorBackground)localBackground).getColor());
      double d1 = (paramInt1 - localBarcodeImpl.getWidth()) / 2;
      double d2 = (paramInt2 - localBarcodeImpl.getHeight()) / 2;
      localBarcodeImpl.draw((Graphics2D)paramGraphics, (int)d1, (int)d2);
    }
    catch (BarcodeException localBarcodeException)
    {
      FRContext.getLogger().log(Level.WARNING, localBarcodeException.getMessage(), localBarcodeException);
    }
  }

  public String toString()
  {
    return "";
  }

  public Object clone()
    throws CloneNotSupportedException
  {
    return super.clone();
  }

  public void readXML(XMLableReader paramXMLableReader)
  {
  }
}